<!-- Site & Page Meta Data -->
{{- $gohugoio := "gohugoio" -}}
{{- $themeColor := "#02b875" -}}
{{- $favicon := "favicon.ico" -}}
{{- $icon16 := "icons/icon-16x16.png" -}}
{{- $icon32 := "icons/icon-32x32.png" -}}
{{- $icon144 := "icons/icon-144x144.png" -}}
{{- $icon152 := "icons/icon-152x152.png" -}}
{{- $icon192 := "icons/icon-192x192.png" -}}
{{- $manifest := "manifest.json" -}}
{{- $bg := resources.Get (.Site.Params.bg | default "images/grey-prism.svg") -}}
{{- $avatar := resources.Get (.Site.Params.avatar | default "images/avatar.png") -}}
{{- $style := resources.Get "styles/main.scss" | resources.ToCSS | resources.Minify -}}
{{- $customStyle := resources.Get (.Site.Params.customStyle | default "styles/custom.scss") | resources.ToCSS | resources.Minify -}}

  <!-- DNS Prefetch -->
  <link href="//cdn.jsdelivr.net" rel="dns-prefetch">
  <link href="//cdnjs.cloudflare.com" rel="dns-prefetch">
  <link href="//at.alicdn.com" rel="dns-prefetch">
  <link href="//fonts.googleapis.com" rel="dns-prefetch">
  <link href="//fonts.gstatic.com" rel="dns-prefetch">
  {{ with .Site.DisqusShortname }}<link href="///disqus.com" rel="dns-prefetch">{{ end }}
  {{ with .Site.DisqusShortname }}<link href="//c.disquscdn.com" rel="dns-prefetch">{{ end }}
  {{ with .Site.Params.Gitment }}<link href="//imsun.github.io" rel="dns-prefetch">{{ end }}
  {{ with .Site.GoogleAnalytics }}<link href="//www.google-analytics.com" rel="dns-prefetch">{{ end }}
  {{ with .Site.Params.baidutongji }}<link href="//hm.baidu.com" rel="dns-prefetch">{{ end }}

  {{ if and (eq .Kind "page") (eq .Type "post") }}

  <!-- Page Author & Description -->
  {{ with .Params.author }}<meta name="author" content="{{ . }}">{{ end }}
  <meta name="description" content="{{ .Summary | plainify }}">

  <!-- Twitter Card -->
  {{ if isset .Params "cover" }}
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@{{ .Site.Params.twitter | default $gohugoio }}">
    <meta name="twitter:title" content="{{ .Title }}">
    <meta name="twitter:description" content="{{ .Summary | plainify }}">
    <meta name="twitter:image" content="{{ .Params.cover | absURL }}">
  {{ else }}
    <meta name="twitter:card" content="summary">
    <meta name="twitter:site" content="@{{ .Site.Params.twitter | default $gohugoio }}">
    <meta name="twitter:title" content="{{ .Title }}">
    <meta name="twitter:description" content="{{ .Summary | plainify }}">
    <meta name="twitter:image" content="{{ $avatar.RelPermalink }}">
  {{ end }}

  <!-- Facebook Open Graph -->
  <meta property="og:type" content="article">
  <meta property="og:title" content="{{ .Title }}">
  <meta property="og:description" content="{{ .Summary | plainify }}">
  <meta property="og:url" content="{{ .Permalink }}">
  <meta property="og:image" content="{{ if isset .Params "cover" }}{{ .Params.cover | absURL }}{{ else }}{{ $avatar.RelPermalink }}{{ end }}">

{{ else }}

  <!-- Site Author & Description -->
  {{ with .Site.Params.author }}<meta name="author" content="{{ . }}">{{ end }}
  {{ with .Site.Params.description }}<meta name="description" content="{{ . }}">{{ end }}

  <!-- Twitter Card -->
  <meta name="twitter:card" content="summary">
  <meta name="twitter:site" content="@{{ .Site.Params.twitter | default $gohugoio }}">
  <meta name="twitter:title" content="{{ if isset .Site.Params "seotitle" }}{{ .Site.Params.seotitle }}{{ else }}{{ .Site.Title }}{{ end }}">
  {{ with .Site.Params.description }}<meta name="twitter:description" content="{{ . }}">{{ end }}
  <meta name="twitter:image" content="{{ $avatar.RelPermalink }}">

  <!-- Facebook Open Graph -->
  <meta property="og:type" content="website">
  <meta property="og:title" content="{{ if isset .Site.Params "seotitle" }}{{ .Site.Params.seotitle }}{{ else }}{{ .Site.Title }}{{ end }}">
  {{ with .Site.Params.description }}<meta property="og:description" content="{{ . }}">{{ end }}
  <meta property="og:url" content="{{ .Permalink }}">
  <meta property="og:image" content="{{ $avatar.RelPermalink }}">

{{ end }}

<!-- Site Generator -->
<meta name="generator" content="Hugo {{ .Hugo.Version }}">

<!-- Permalink & RSSlink -->
<link rel="canonical" href="{{ .Permalink }}">
{{ range .AlternativeOutputFormats -}}
  {{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}

<!-- Rending Prefs -->
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="format-detection" content="telephone=no,email=no,adress=no">
<meta http-equiv="Cache-Control" content="no-transform">

<!-- SEO Prefs -->
<meta name="robots" content="index,follow">
<meta name="referrer" content="origin-when-cross-origin">
{{ with .Site.Params.googlesiteverification }}<meta name="google-site-verification" content="{{ . }}">{{ end }}
{{ with .Site.Params.msvalidate }}<meta name="msvalidate.01" content="{{ . }}">{{ end }}
{{ with .Site.Params.baidusiteverification }}<meta name="baidu-site-verification" content="{{ . }}">{{ end }}
{{ with .Site.Params.sogousiteverification }}<meta name="sogou_site_verification" content="{{ . }}">{{ end }}
{{ with .Site.Params.sositeverification }}<meta name="360-site-verification" content="{{ . }}">{{ end }}

<!-- Favicon and Touch icons -->
<meta name="theme-color" content="{{ $themeColor }}">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}">
<meta name="msapplication-tooltip" content="{{ .Site.Title }}">
<meta name='msapplication-navbutton-color' content="{{ $themeColor }}">
<meta name="msapplication-TileColor" content="{{ $themeColor }}">
<meta name="msapplication-TileImage" content="{{ $icon144 | relURL }}">
<link rel="icon" href="{{ $favicon | relURL }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ $icon16 | relURL }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ $icon32 | relURL }}">
<link rel="icon" sizes="192x192" href="{{ $icon192 | relURL }}">
<link rel="apple-touch-icon" href="{{ $icon152 | relURL }}">
<link rel="manifest" href="{{ $manifest | relURL }}">

<!-- Preload -->
<link rel="preload" href="{{ $style.RelPermalink }}" as="style">
{{ with .Site.Params.customStyle }}<link rel="preload" href="{{ $customStyle.RelPermalink }}" as="style">{{ end }}
<link rel="preload" href="https://fonts.googleapis.com/css?family=Lobster" as="style">
<link rel="preload" href="{{ $avatar.RelPermalink }}" as="image">
<link rel="preload" href="{{ $bg.RelPermalink }}" as="image">

<!-- Main Styles -->
<style>
  body {
    background: rgb(244, 243, 241) url('{{ $bg.RelPermalink }}') repeat fixed;
  }
</style>
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{ with .Site.Params.customStyle }}<link rel="stylesheet" href="{{ $customStyle.RelPermalink }}">{{ end }}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lobster">

<!-- Medium Zoom -->
{{ if and (eq .Kind "page") (eq .Type "post") }}
<script src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.2/dist/medium-zoom.min.js"></script>
{{ end }}

<!-- Video.js Styles -->
{{ if and (eq .Kind "page") (eq .Type "post") }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/video.js@7.3.0/dist/video-js.min.css">
{{ end }}
